package cn.zbh._02_xhr_a;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("xhr-a");
        producer.setNamesrvAddr("localhost:9876");

        producer.start();
        Message message = new Message("producer_xhr", "xhr", "快毕业了".getBytes(StandardCharsets.UTF_8));
         producer.send(message, new SendCallback() {
             @Override
             public void onSuccess(SendResult sendResult) {
                 System.out.println("成功消费");
             }

             @Override
             public void onException(Throwable throwable) {
                 throwable.printStackTrace();
                 System.out.println("消费失败");

             }
         });



    }
}
